# -*- coding: utf-8 -*-
import oss2
import os
auth = oss2.Auth('LTAI5tAmSbMPjo6FCn86VXjL', 'PA6UqeKe78EiyqVHdfBMcsaP5XktBB')

bucket = oss2.Bucket(auth, 'https://oss-cn-shanghai.aliyuncs.com', 'zhangqichuan-ai-test')

bucket.put_object_from_file('test.jpg', '/root/test.jpg')  



url = bucket.sign_url('GET', 'test.jpg', 60, slash_safe=True)     
print url



from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkcore.auth.credentials import StsTokenCredential
from aliyunsdkocr.request.v20191230.RecognizeCharacterRequest import RecognizeCharacterRequest

credentials = AccessKeyCredential('LTAI5tAmSbMPjo6FCn86VXjL', 'PA6UqeKe78EiyqVHdfBMcsaP5XktBB')
# use STS Token
# credentials = StsTokenCredential('<your-access-key-id>', '<your-access-key-secret>', '<your-sts-token>')
client = AcsClient(region_id='cn-shanghai', credential=credentials)

request = RecognizeCharacterRequest()
request.set_accept_format('json')

#url="https://zhangqichuan-ai-test.oss-cn-shanghai.aliyuncs.com/test.jpg?OSSAccessKeyId=LTAI5tAmSbMPjo6FCn86VXjL&Expires=1641879051&Signature=pyk11hT4MnlpOlJukZq0SBnl9WE%3D"
request.set_ImageURL(url)
request.set_MinHeight(10)
request.set_OutputProbability(True)

response = client.do_action_with_exception(request)
# python2:  print(response) 
print response
